import SDKManager from "../SDKManager";
import GlobalEvent from "../../cfw/event/GlobalEvent";
import { EventName } from "../../public/Config";

// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const { ccclass, property } = cc._decorator;

@ccclass
export default class ADConfigComp extends cc.Component {



    start() {
        this.updateState();
        GlobalEvent.instance().on(EventName.SORT_AD_DATA, this.updateState, this)
    }

    onDestroy() {
        GlobalEvent.instance().off(EventName.SORT_AD_DATA, this.updateState, this)
    }

    updateState() {
        if (!cc.isValid(this.node)) {
            return;
        }
        let flag = SDKManager.getChannel().isSwtichOpen();
        this.node.active = flag;
    }

    // update (dt) {}
}
